#include "task_50ms.h"
#include "bsp_usb.h"
#include "bsp_rs485.h"
#include "bsp_bc26.h"  
#include "bsp_led.h"
#include "bsp_iwdg.h"
extern RS485_Request_t RS485_Request;   
extern LED_STAT sysStatLed;
uint32_t run_time=0;

TaskHandle_t xHandleTask50ms = NULL;
static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
void vTask_50ms(void *pvParameters)
{
	TickType_t pxPreviousWakeTime = xTaskGetTickCount();
	while(1)
	{
		vTaskDelayUntil(&pxPreviousWakeTime, 1000 / portTICK_RATE_MS );
//		IWDG_Feed(); 
//		USB_FUNCTION();
		LED_Updata(sysStatLed);
		run_time+=1000;
		if(RS485_Request.RState==RS485_Addr)	   
		{
			if(run_time>1000*60*10||RS485_Request.request_InitEnd==1) // 数组获取后立即执行一次
			{
				run_time = 0;
				RS485_Send_AND_Check(RS485_Request.Total_energy,20,18);
			}
		}
		else if(RS485_Request.RState == Init)
		{
				RS485_GetAddress();         
		}
		
		RS485_Handle();
	}
}



